package httpService

import (
	"github.com/labstack/echo/v4"
	"pm/db"
	"pm/model"
)

func PackageCurrent(c echo.Context)error {
	//获取参数
	//name := c.FormValue("name")
	//current := c.FormValue("current")
	//pageSizeParam := c.FormValue("page_size")
	//pageParam := c.FormValue("page")
	//pageSize := 10
	//page := 1
	//if pageSizeParam != ""{
	//	pageSize,_ = strconv.Atoi(pageSizeParam)
	//}
	//if pageParam != ""{
	//	page,_ = strconv.Atoi(pageParam)
	//}
	var (
		PackageData []model.PackageCurrent
		Total int64
	)
	db.NewDb().Model(&model.PackageCurrent{}).Order("created_at desc").Find(&PackageData)
	//if name != ""{
	//	dbIns.Where("name = ?", name)
	//}
	//if current != "0"{
	//	dbIns.Where("current = ?", 1)
	//}
	//err := dbIns.Limit(pageSize).
	//	Offset((page - 1) * pageSize).
	//dbIns.Order("created_at desc").
	//	//Count(&Total).
	//	Find(&PackageData)
	return c.JSON(200, map[string]interface{}{
		"list": PackageData,
		"total":Total,
	})
}
